<template>
<div>
    <cropchart @posts="posts" @search="search"/>
<div>
</div>
<div>
  <Table border stripe :columns="columns1" :data="data1"></Table>
</div>
</div>
</template>
<script>
import cropchart from '../from/cropchart.vue'
export default {
  data() {
    return {
      columns1: [
        {
          title: "作物号",
          key: "zid",
        },
        {
          title: "作物名",
          key: "zname",
        },
        {
          title: "现存量",
          key: "cropsum",
        },
        {
          title: "安全库存",
          key: "av",
        },
      ],
      data1: [],
    };
  },
  mounted(){
      this.axios.get('/api/deinfo').then((r)=>{
          this.data1=r.data
      }).catch((e)=>{
          this.$Message.error("E"+e)
      })
  },
  components:{
      cropchart,
  },
  methods:{
    posts(data){
      this.axios.post('/api/crop',data).then((r)=>{
        // this.data1=r.data
        this.$Message.info(r.data)
      }).catch((e)=>{
        this.$Message.error("e"+e)
      })
      this.axios.get('/api/deinfo').then((r)=>{
          this.data1=r.data
      }).catch((e)=>{
          this.$Message.error("E"+e)
      })
    },
    search(data){
      this.axios.get('/api/crop',{params:{param:data}}).then((r)=>{
        this.data1=r.data
      }).catch((e)=>{
        this.$Message.error("e"+e)
      })
    }
  }
};
</script>
